package com.sgb.kjwl.view.widget.enterprise;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.recyclerview.widget.LinearLayoutManager;

import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.enterprise.ServiceProcessesEntity;
import com.sgb.kjwl.view.ui.adapter.enterprise.ServicePopNodeAdapter;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;
import com.sgb.kjwl.view.widget.MaxHeightRecyclerView;

import java.util.List;

public class ServiceNodePopWindow extends BasePopWindow {

    private MaxHeightRecyclerView recyclerView;
    private ImageView closeView;
    private ServicePopNodeAdapter servicePopNodeAdapter;
    private List<ServiceProcessesEntity> mData;
    private LinearLayout noDataLay;

    public ServiceNodePopWindow(Context context) {
        super(context, DIR_DOWN_UP);
    }

    @Override
    protected int popLayout() {
        return R.layout.popwindow_service_node;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        recyclerView = holder.getPop().findViewById(R.id.node_list_max);
        closeView = holder.getPop().findViewById(R.id.close_view);
        noDataLay = holder.getPop().findViewById(R.id.ll_empty);
        closeView.setOnClickListener(v -> dissMiss());
        servicePopNodeAdapter = new ServicePopNodeAdapter(mContext, null);
        servicePopNodeAdapter.setItemSelect(false);
        recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        recyclerView.setAdapter(servicePopNodeAdapter);
        closeView.setOnClickListener(v -> dismiss());
    }

    public void setData(List<ServiceProcessesEntity> data) {
        if (data == null || data.size() == 0) {
            servicePopNodeAdapter.setDatasMayNull(null);
            noDataLay.setVisibility(View.VISIBLE);
        } else {
            servicePopNodeAdapter.setDatas(data);
        }
    }
}
